/**
 * Created by 陈奇 on 2015/1/19.
 */
var express = require('express');
var router = express.Router();
var db = require('./conn');//先引入数据库链接

router.get('/', function(req, res) {
    var userupdate = req.param('username');
    var passupdate = req.param('userpass');

    db.pool.getConnection(function(err, connection) {
        var sql = 'update userinfo set UserPass = ? where UserName = ?';
        var sql_val = [passupdate,userupdate];
        connection.query( sql,sql_val, function(err, result) {
            if(err){
                console.log('修改密码失败!');
            }else{
                console.log('密码修改生效!');
            }
        });
        connection.release();
    });

    res.render('update',{ title: '修改密码' });
});

module.exports = router;